﻿using System;
using System.Text;
using TI_BLE_HCI_ClientLib.BaseEntities;
using TI_BLE_HCI_ClientLib.GenericHCIEntities;
using TI_BLE_HCI_ClientLib.HCIBaseEntities;

namespace TI_BLE_HCI_ClientLib.HCICommands
{
    public class HCICommand_GATT_Error_Response : HCIVendorSpecificCommand
    {
        private const byte CMD = 0x01;

        public enum RequestOpCodeEnum : byte
        {
            ReadRequest=0x0A,
            WriteRequest=0x12
        }

        public enum ErrorCodeEnum : byte
        {
            AttributeHandleNotValid=0x01,
            AttributeCannotBeRead=0x02,
            AttributeCannotBeWritten=0x03,
            AttributeNotFound=0x0A
        }

        public HCICommand_GATT_Error_Response(ushort connHandle, RequestOpCodeEnum reqOpCode, ushort attributeHandle, ErrorCodeEnum errCode)
            : base(HCIVendorSpecificCommandCSG.ATT, CMD)
        {
            var pars = new BaseEntityParameter[4];

            pars[0] = new WordParameter(connHandle);
            pars[1] = new ByteParameter((byte)reqOpCode);
            pars[2] = new WordParameter(attributeHandle);
            pars[3] = new ByteParameter((byte)errCode);

            base.addParameters(pars);
        }

    }
}
